package com.ruoyi.web.controller.market.product;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.db.domain.ProductProfit;
import com.ruoyi.db.domain.ProductProfitAddup;
import com.ruoyi.db.model.param.ChannelInfoParam;
import com.ruoyi.extend.service.IChannelInfoService;
import com.ruoyi.product.service.IProductProfitAddupService;
import com.ruoyi.product.service.IProductProfitService;
import com.ruoyi.web.wapper.ProductProfitAddupWapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * profitAddupController
 * 
 * @author ruoyi
 * @date 2022-08-31
 */
@Controller
@RequestMapping("/product/qiv")
public class ProductQiVController extends BaseController
{
    private String prefix = "product/qiv";

    @Autowired
    private IProductProfitAddupService productProfitAddupService;

    @RequiresPermissions("product:qiv:list")
    @GetMapping("")
    public String profitAddup(ModelMap mmap)
    {
        return prefix + "/qivhome";
    }

    /**
     * 查询profitAddup列表
     */
    @RequiresPermissions("product:qiv:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ProductProfitAddup productProfitAddup)
    {
        if (!ShiroUtils.getSysUser().isAdmin()){
            productProfitAddup.setUserId(ShiroUtils.getUserId());
        }

        startPage();
        List<Map<String, Object>> mapList = productProfitAddupService.selectProductProfitAddupQIVListMap(productProfitAddup);
        mapList = new ProductProfitAddupWapper(mapList).wrap();
        return getDataTable(mapList);
    }

}
